package managedbean.SCM.DeliveryOrder;
import entity.SCM.DeliveryOrder;
import java.io.IOException;
import java.io.Serializable;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import session.stateless.SCM.DeliveryOrderBeanLocal;

@ManagedBean (name = "successDeliveryOrderTable")
@ViewScoped
public class SuccessDeliveryOrderManagerBean implements Serializable {

    public SuccessDeliveryOrderManagerBean() {    }
    
    @EJB
    DeliveryOrderBeanLocal diliveryOrderBeanLocal;
    private DeliveryOrder selectedDeliveryOrder;
    private String statusMessage;

    public DeliveryOrder getSelectedDeliveryOrder() {
        return selectedDeliveryOrder;
    }

    public void setSelectedDeliveryOrder(DeliveryOrder selectedDeliveryOrder) {
        this.selectedDeliveryOrder = selectedDeliveryOrder;
    }

    public String getStatusMessage() {
        return statusMessage;
    }

    public void setStatusMessage(String statusMessage) {
        this.statusMessage = statusMessage;
    }
    
    public List<DeliveryOrder> getSuccessDeliveryOrder(){
        return diliveryOrderBeanLocal.getSuccessDeliveryOrder();
    }
    
    //Pass to Daniel's FRM to process invoice
    public void createInvoice(ActionEvent event) throws IOException{
        FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("selectedDeliveryOrder", selectedDeliveryOrder);
        FacesContext.getCurrentInstance().getExternalContext().redirect("../customerInvoice/addCustomerInvoice.xhtml");
    
    }
}
